import pymysql

con = pymysql.connect(host='localhost', user='root', password='123456', database='1_test', port=3306,
                      charset='utf8')
cursor = con.cursor()
try:
    with con.cursor() as cursor:
        sql2 = 'select count() from net'
        cursor.execute(sql2)
        rows = cursor.fetchall()
        print(rows)
        con.commit()
finally:
    cursor.close()
    con.close()
